﻿function AppCtrl($scope) {
    $scope.appTitle = 'learning-angular-js';
}

function TodoCtrl($scope) {
    $scope.todos = [
        { title: 'learn angularjs', done: false },
        { title: 'install resharper-angularjs', done: true },
        { title: 'do a harlem shake', done: false }
    ];

    $scope.addTodoItem = function () {
        if ($scope.todoItemToAdd === '' || $scope.todoItemToAdd === undefined)
            return;

        $scope.todos.push({
            title: $scope.todoItemToAdd,
            done: false
        });
        $scope.todoItemToAdd = '';
    };

    $scope.clearCompletedTodos = function() {
        $scope.todos = $scope.todos.filter(function(todo) {
            return !todo.done;
        });
    };
}